package net
{
	import flash3.net.ByteArrayPlus;
	import flash3.net.MsgPacket;
	
	import model.*;
	
	import vo.*;

	public class ConfigGroup extends MessageGroup
	{
		//配置信息数据包
		public static const MDM_GR_INFO:uint					=	203									//配置信息
		public static const SUB_GR_SERVER_INFO	:uint			=	100									//房间配置
		public static const SUB_GR_ORDER_INFO:uint				=	101									//等级配置
		public static const SUB_GR_MEMBER_INFO	:uint			=	102									//会员配置
		public static const SUB_GR_COLUMN_INFO	:uint			=	103									//列表配置
		public static const SUB_GR_CONFIG_FINISH:uint			=	104									//配置完成
				
		public function ConfigGroup()
		{
			super();
		}
		
		override public function defMessage():void
		{
			addMessage(new MessageDef(MDM_GR_INFO, SUB_GR_SERVER_INFO, "房间配置", onServerInfo));
			addMessage(new MessageDef(MDM_GR_INFO, SUB_GR_ORDER_INFO, "等级配置", onOrderInfo));
			addMessage(new MessageDef(MDM_GR_INFO, SUB_GR_MEMBER_INFO, "会员配置", onMemberInfo));
			addMessage(new MessageDef(MDM_GR_INFO, SUB_GR_COLUMN_INFO, "配置列表", onColumInfo));
			addMessage(new MessageDef(MDM_GR_INFO, SUB_GR_CONFIG_FINISH, "配置完成", onConfigFinish));
		}
		public function onServerInfo(packet:MsgPacket):void
		{
			var bap:ByteArrayPlus = packet._data;
			var serverInfo:ServerInfo = new ServerInfo();
			serverInfo.wKindID = bap.readShort();
			serverInfo.wSiteID = bap.readShort();
			serverInfo.wTableCount = bap.readShort();
			serverInfo.wChairCount = bap.readShort();
			serverInfo.dwVideoAddr = bap.readUnsignedInt();
			serverInfo.wGameGenre = bap.readUnsignedInt();
			serverInfo.cbHideUserInfo = bap.readByte();
			MeInfoModel.i.serverInfo = serverInfo;
		}
		public function onOrderInfo(packet:MsgPacket):void
		{
		}
		public function onMemberInfo(packet:MsgPacket):void
		{
		}
		public function onColumInfo(packet:MsgPacket):void
		{
			var bap:ByteArrayPlus = packet._data;
			if(bap.bytesAvailable < 1) return;
			var length:uint = bap.readShort();
			var desc:String = "";
			for(var i:uint = 0;i < length; i++)
			{
				var columnItem:ColumnItem = new ColumnItem();
				columnItem.wColumnWidth = bap.readShort();
				columnItem.wDataDescribe = bap.readShort();
				columnItem.szColumnName = bap.readUTFBytes(ColumnItem.NAME_LEN);
				ColumnInfoModel.i.add(columnItem);
//				desc += columnItem.szColumnName+"/";
				
			}
//			trace(desc);
		}
		public function onConfigFinish(packet:MsgPacket):void
		{
		}
	}
}